
from apps.libs.error import APIException

'''
200 请求成功
201 创建更新成功
204 删除成功
301 302 重定向
400 请求参数错误
401 未授权
403 禁止访问
404 未找到页面
500 服务器内部错误
'''
class Success(APIException):
    code = 200
    msg = 'ok'
    # 操作成功用0表示
    error_code = 200


class DeleteSuccess(Success):
    code = 202
    # 删除成功用-1表示
    error_code = -1


class ClientTypeError(APIException):
    code = 400
    msg = 'client is invalid'
    error_code = 1006


class ParameterException(APIException):
    code = 400
    msg = 'invatid paramater'
    error_code = 1000


class ServerError(APIException):
    code = 500
    msg = 'server error!'
    error_code = 999


class NotFound(APIException):
    code = 404
    msg = 'the resource not found'
    error_code = 1001


class AuthFailed(APIException):
    code = 401
    msg = 'authorization failed'
    error_code = 1005


class Forbidden(APIException):
    code = 403
    error_code = 1004
    msg = 'forbidden, not in scope'
